#!/user/bin/env python3
# -*- coding: utf-8 -*-
"""
--------------------------------------
    Author:     JiChao_Song
    Date  :     2021/11/12 15:58
    Desc  :
--------------------------------------
"""
import time

from django.db import models
from mongoengine import Document, fields


def get_time():
    return int(time.time() * 1000)


class AbstractBaseModel(models.Model):
    createTime = models.BigIntegerField(default = get_time, help_text = '创建时间')
    creatorName = models.CharField(max_length = 255, null = True, blank = True, help_text = '创建人')
    creatorId = models.IntegerField(null = True, blank = True, help_text = '创建人')
    updateTime = models.BigIntegerField(null = True, blank = True, help_text = '修改时间')
    updaterName = models.CharField(max_length = 255, null = True, blank = True, help_text = '修改人姓名')
    updaterId = models.IntegerField(null = True, blank = True, help_text = '修改人Id')
    deleted = models.BooleanField(default = False, help_text = '逻辑删除标识')
    deleteTime = models.BigIntegerField(null = True, blank = True, help_text = '删除时间')
    remark = models.CharField(max_length = 1000, null = True, blank = True, help_text = '备注')

    class Meta:
        abstract = True


class AbstractBaseDocument(Document):
    # 创建时间
    createTime = fields.IntField(default = get_time)
    # 创建人
    creatorName = fields.StringField(null = True)
    # 创建人id
    creatorId = fields.IntField(null = True)
    # 更新时间
    updateTime = fields.IntField(null = True)
    # 更信任姓名
    updaterName = fields.StringField(null = True)
    # 更新热id
    updaterId = fields.IntField(null = True)
    # 逻辑删除标识
    deleted = fields.BooleanField(default = False)
    # 删除时间
    deleteTime = fields.IntField(null = True)

    meta = {'abstract': True,}  # 抽象, 这里要设置为True
